package com.bys.server;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.UUID;

@Service
@EnableBinding(Source.class) // 消息发送的一个管道
public class MessageService {
    @Resource
    private MessageChannel output;
    public String send(){
        String id = UUID.randomUUID().toString().replaceAll("-", "");
        String message = id + " 发送消息 成功";
        output.send(MessageBuilder.withPayload(message).build());
        return message;
    }


}
